<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/6
 * Time: 10:20
 */
 $name=$_POST['user_name'];
 $pwd=$_POST['user_pwd'];
 if($name=='admin'&&$pwd=='888888'){
   setcookie('Token',md5($name.$pwd.time()),time()+24*3600);
 }
 if(!empty($_COOKIE['Token'])){
    echo '存在';
 }
 else{
     echo '不存在';
     die;
 }
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>欢迎来到用户中心页面</h1>
    <form method="post" enctype="multipart/form-data" action="index3.php" >
        <table>
            <tr>
                <td>当前头像</td>
                <td><img id="img" name="img" src="t_images\img\c13.webp" width="150px" height="150px"></td>
            </tr>
            <tr>
                <td>上传头像:</td>
                <td>
                    <input type="file" id="file_img" name="file_img" onchange="showImg()"><br/>
                </td>
            </tr>
        </table>
        <input type="submit"
        <?php
        move_uploaded_file($_FILES['file_img']['tmp_name'],'t_images/img/'.$_FILES['file_img']['name']);
        ?>>
    </form>
</body>
<script type="text/javascript">
    var fileObj = document.getElementById('file_img');
    function showImg() {
        var files = fileObj['files'];
        var URL = window.URL || window.webkitURL;
        var imgURL = URL.createObjectURL(files[0]);
        document.getElementById('img').src = imgURL;
    }

</script>
</html>
